import type { EntityDto } from '@/models/entity';
import type { PagedResultDto } from '@/models/paged-result';
import type { RoleResultDto } from '@/models/role';
import type { UserDto, UserResultDto, UserResultRequestDto } from '@/models/user';
import { ContentType, httpApi } from '@/utils/axios/http';
import url from '@/utils/axios/url';

export function getUsersApi(input: UserResultRequestDto): Promise<PagedResultDto<UserResultDto>> {
    return httpApi.httpGet({ url: url.user, params: input });
}

export function getUserApi(id: number): Promise<UserResultDto> {
    return httpApi.httpGet({ url: url.user + '/' + id });
}

export function getRoleListApi(): Promise<Array<RoleResultDto>> {
    return httpApi.httpGet({ url: url.user + '/roles' });
}

export function postUserApi(input: UserDto): Promise<UserResultDto> {
    return httpApi.httpPost({ url: url.user, params: input, contentType: ContentType.FormData });
}

export function putUserApi(input: UserDto): Promise<UserResultDto> {
    return httpApi.httpPut({ url: url.user, params: input, contentType: ContentType.FormData });
}

export function putRecoverApi(input: EntityDto): Promise<UserResultDto> {
    return httpApi.httpPut({ url: url.user + '/recover', params: input });
}

export function putEnableApi(input: EntityDto): Promise<UserResultDto> {
    return httpApi.httpPut({ url: url.user + '/enable', params: input });
}

export function putDisableApi(input: EntityDto): Promise<UserResultDto> {
    return httpApi.httpPut({ url: url.user + '/disable', params: input });
}

export function putDeletePhotoApi(input: UserDto): Promise<UserResultDto> {
    return httpApi.httpPut({ url: url.user + '/deletePhoto', params: input });
}

export function deleteUserApi(id: number): Promise<EntityDto> {
    return httpApi.httpDelete({ url: url.user + '/' + id });
}